package com.HeJing.面向对象特征之一_封装;

/**
 * ClassName: Person
 * Package: com.HeJing.封装
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-24 11:26
 * @Version: 1.0
 */
public class Person {
    // 属性:
    String name;
    private int age;

    // 方法:
    // 设置age属性
    public void setAge(int a) {
        if(a >= 0 && a <= 130) {
            age = a;
        } else {
            System.out.println("输入的年龄数据非法!");
        }
    }

    public int getAge() {
        return age;
    }
}




























